<?php
include_once '../classes/dao.php';
include_once '../classes/sugestoes.php';

$dao = new DAO();

if (!isset($_REQUEST["term"])) {
	exit;
}

$consulta = $_REQUEST["term"];

$tags = $dao->consulta_tags($consulta);

$sugestoes = new Sugestoes();
foreach ($tags as $tag) {
	$sugestoes->adicionar_sugestao($tag->get_id(), $tag->get_tag());
}

echo $sugestoes->get_json();
?>